import axios from 'axios'

const Mock = require('mockjs')
const Random = Mock.Random

Random.extend({
  phone: function () {
    var phonePrefixs = ['132', '135', '189'] // 自己写前缀哈
    return this.pick(phonePrefixs) + Mock.mock(/\d{8}/) //Number()
  }
})

// 积分支出列表
Mock.mock('/api/getExpendtList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      userInfo: {
        name: Random.cname(),
        mobile: Random.phone()
      },
      remark: Random.cword(5, 10),
      integral: Random.integer(0, 10000),
      balance: Random.integer(0, 10000),
      createdTime: Random.date('yyyy-MM-dd hh:mm:ss'),
      origin: Random.pick([1, 2, 3, 4])
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(0, 10000)
  }
})

// 积分收入列表
Mock.mock('/api/getIncomeList', () => {
  let list = []
  for (let index = 0; index < 30; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      userInfo: {
        name: Random.cname(),
        mobile: Random.phone()
      },
      convertType: Random.pick([1, 2, 3]),
      orderNo: Random.character('number', 15),
      integral: Random.integer(0, 10000),
      balance: Random.integer(0, 10000),
      createdTime: Random.date('yyyy-MM-dd hh:mm:ss'),
      origin: Random.pick([1, 2, 3, 4])
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(0, 10000)
  }
})

// 结算单待审核列表
Mock.mock('/api/getPendingList', () => {
  let list = []
  for (let index = 0; index < 20; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      settleMonth: `2021年${Random.pick([1, 2, 3, 4])}月`,
      settlePeriod: `${Random.date('yyyy-MM-dd hh:mm:')}至${Random.date('yyyy-MM-dd hh:mm:')}`,
      getIntegral: Random.integer(0, 10000),
      convertIntegral: Random.integer(0, 10000),
      loseIntegral: Random.integer(0, 10000),
      createdTime: Random.date('yyyy-MM-dd hh:mm'),
      settleSatus: 1
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(0, 10000)
  }
})

// 结算单已结算列表
Mock.mock('/api/getSettleList', () => {
  let list = []
  for (let index = 0; index < 20; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      settleMonth: `2021年${Random.pick([1, 2, 3, 4])}月`,
      settlePeriod: `${Random.date('yyyy-MM-dd hh:mm:')}至${Random.date('yyyy-MM-dd hh:mm:')}`,
      getIntegral: Random.integer(0, 10000),
      convertIntegral: Random.integer(0, 10000),
      loseIntegral: Random.integer(0, 10000),
      createdTime: Random.date('yyyy-MM-dd hh:mm'),
      settleSatus: 2
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(0, 10000)
  }
})

// 积分兑换列表
Mock.mock('/api/getConvertList', () => {
  let list = []
  for (let index = 0; index < 20; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      userInfo: {
        name: Random.cname(),
        mobile: Random.phone()
      },
      Dispositon: Random.cword(5, 10),
      integral: Random.integer(0, 10000),
      status: Random.pick([1, 2]),
      reason: Random.cword(5, 10),
      handler: {
        name: Random.cname(),
        time: Random.date('yyyy-MM-dd hh:mm')
      },
      convertTime: Random.date('yyyy-MM-dd hh:mm'),
      accountTime: Random.date('yyyy-MM-dd hh:mm'),
      balance: Random.integer(0, 10000)
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(0, 10000)
  }
})

// 积分获得列表
Mock.mock('/api/getIntegralGetList', () => {
  let list = []
  for (let index = 0; index < 20; index++) {
    let listObject = {
      id: Random.integer(0, 10000),
      orgin: Random.pick([1]),
      integral: Random.integer(0, 10000),
      orderNo: Random.character('number', 15),
      getTime: Random.date('yyyy-MM-dd hh:mm'),
      accountStatus: Random.pick([1]),
      accountTime: Random.date('yyyy-MM-dd hh:mm'),
      balance: Random.integer(0, 10000)
    }
    list.push(listObject)
  }
  return {
    list,
    total: Random.integer(0, 10000)
  }
})

export function getExpendtList() {
  return axios.get('/api/getExpendtList')
}

export function getIncomeList() {
  return axios.get('/api/getIncomeList')
}

export function getPendingList() {
  return axios.get('/api/getPendingList')
}

export function getSettleList() {
  return axios.get('/api/getSettleList')
}

export function getConvertList() {
  return axios.get('/api/getConvertList')
}

export function getIntegralGetList() {
  return axios.get('/api/getIntegralGetList')
}
